package com.ww.learn.oop.sam

fun interface StringTransformer {
    fun transform(input: String): String
}

// 使用lambda创建实例
val upperCaseTransformer = StringTransformer { it.uppercase() }
val reverseTransformer = StringTransformer { it.reversed() }

fun processString(input: String, transformer: StringTransformer): String {
    return transformer.transform(input)
}

fun main() {
    val result1 = processString("Hello", upperCaseTransformer)
    val result2 = processString("hello") { it.reversed() } // 使用lambda创建实例

    // 打印结果
//    HELLO
//    olleh
    println(result1)
    println(result2)
}